package com.weipai.springboot.module.mapper;

import com.weipai.springboot.model.SpecialOffer;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;
import tk.mybatis.mapper.common.MySqlMapper;

import java.util.List;

/**
 * 会场活动
 */
public interface SpecialOfferMapper{

    int deleteByPrimaryKey(String specialOfferId);

    int insert(SpecialOffer record);

    int insertSelective(SpecialOffer record);

    SpecialOffer selectByPrimaryKey(String specialOfferId);

    int updateByPrimaryKeySelective(SpecialOffer record);

    int updateByPrimaryKey(SpecialOffer record);

    //查询未删除（删除）的数据
    List<SpecialOffer> selectAllByDel(int del);

    //查询会场详情
    SpecialOffer getSpecialOfferById(String specialOfferId);

    //删除
    @Update("update c_special_offer set special_offer_del=-1, del_time=date_format(now(), '%Y-%m-%d %H:%i:%s') " +
            "where special_offer_id=#{specialOfferId}")
    int updateDel(String specialOfferId);

    //更改会场活动的状态
    @Update("update c_special_offer set special_offer_status=#{status}, del_time=date_format(now(), '%Y-%m-%d %H:%i:%s') " +
                   "where special_offer_id=#{specialOfferId}")
    int updateStatus(@Param("specialOfferId") String specialOfferId, @Param("status") Integer status);

    //批量删除
    int batchDeleteById(String[] id);

    //查询总数量
    Integer selectAllByPageAmount(Integer type);

    //分页查询
    List<SpecialOffer> selectAllByPage(@Param("start") Integer start, @Param("end") Integer end, @Param("type") Integer type);

    //  APP  首页 获取 举办会场详情
    List<SpecialOffer> getSpecialOffer();
}